<?php
include "Database/koneksi.php";

	$sql = mysql_query("SELECT Menu_ID, MenuDisplay, Link, HeaderMenu_ID FROM menu  WHERE MenuLevel=0 AND IsAdmin='N' AND IsDisplay='Y'  ORDER BY Sequence");
	
	while($result=mysql_fetch_array($sql))
	{	
		$id0 = $result[0];
		if($result[3]=="NULL" ) 
		{
			if($result[1]=="Home") {
				echo "<li><a href='". $_SERVER['PHP_SELF']."'>".$result[1]."</a></li>";
			}
			else {
				echo "<li><a href='".$result[2]."' target='frame'>".$result[1]."</a></li>";
			}
		}
		else {
			echo "<li><a href='".$result[2]."' target='frame'>".$result[1]."</a>";
			
			  	$sql1 = mysql_query("Select count(*) from menu where headerMenu_ID = $id0");
				  
			  	if($result1=mysql_fetch_array($sql1))
			  	{	
				  	if($result1[0]>0)
				  	{
					  echo "<ul>";
					  	$sql2 = mysql_query("SELECT Menu_ID, MenuDisplay, Link, HeaderMenu_ID FROM menu  WHERE MenuLevel=1 AND IsAdmin='N' AND IsDisplay='Y'  and headerMenu_ID = $id0 ORDER BY Sequence");
					  	while($result2=mysql_fetch_array($sql2))
					  	{
						  	$id1 = 	$result2[0];
						  	if($result2[3]=="NULL")
							  	echo "<li><a href='".$_SERVER['PHP_SELF']."?function$result2[0]=2&tid=$result2[3]' target='frame'>".$result2[1]."</a></li>";
						  	else
							  	echo "<li><a href='".$_SERVER['PHP_SELF']."?function$result2[0]=2&amid=$result2[2]&tid=1' target='frame'>".$result2[1]."</a></li>";
					  	}	
					  echo"</ul>";				
				  	}		  
			  	}
			echo"</li>";		
		}
	}//echo "</li>";
?>